<template>
	<view class="content">
		<template v-if="list.length>0">
			<PositionItem :key="item.id" :data="item" v-for="(item) in list"></PositionItem>
		</template>
		<view v-else-if="list.length==total&&!more&&list.length!==0" style="text-align: center;">没有更多了哦</view>
		<view v-else style="text-align: center;">暂无数据</view>
	</view>
</template>

<script>
	import {
		getCustomerListApi,
		getPublishApi,
		getHotEnterprise
	} from '@/api/job_hunting.js';
	import {
		isMore
	} from '@/util/util.js'
	import PositionItem from "@/page_other/job_hunting/recruit_list/index.vue";
	export default {
		components: {
			PositionItem
		},
		data() {
			return {
				list: [],
				page: 1,
				limit: 10,
				more: true,
				total: 0,
				addressType: '',
			}
		},
		methods: {
			async getList(refresh = false) {
				var latitude = uni.getStorageSync('latitude');
				var longitude = uni.getStorageSync('longitude');
				if (this.more) {
					let config = {
						page: this.page,
						limit: this.limit,
						addressType: this.addressType
					}
					uni.showLoading({
						title: '加载中',
						mask: true
					})
					let res = this.$store.getters.identity == 1 ? await getPublishApi(config) :
						await getCustomerListApi(config);
					let list = res.list ?? [];
					this.list = refresh ? list : [...this.list, ...list]
					console.log(res)
					this.total = res.count
					this.more = isMore(this.page, this.limit, this.total)
				}
			},
			refresh() {
				this.page = 1
				this.more = true
				this.getList(true);
			},
		},
		onPullDownRefresh() {
			this.refresh();
			uni.stopPullDownRefresh();
		},
		onReachBottom() {
			if (this.more) {
				this.page++;
				this.getList()
			}
		},
		onLoad(e) {
			if(e.addressType)
			{
				this.addressType = e.addressType
			}
			this.getList(true)
		}
	}
</script>

<style lang="scss">
	.content {
		padding: 30rpx;
	}
</style>